package com.itheima.day16.work;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/*
*  ArrayList 集合 添加非集合类型定义的元素
* */
public class ArrayListClassDemo {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<String >  al=new ArrayList<String>();
        Class<? extends ArrayList> aClass = al.getClass();
        Method add = aClass.getMethod("add", Object.class);
        add.invoke(al,"hello");
        add.invoke(al,"java");
        add.invoke(al,"world");
        System.out.println(al);
    }
}
